home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / lang / c--c0202 / system.h-- < prev    next >
Encoding:
Text File  |  1994-03-30  |  2.0 KB  |  119 lines

  1. /*
  2.     SPHINX Programming (C) 1994.
  3.     NAME:  SYSTEM.H--
  4.     DESCRIPTION:  This file contains a collection of procedures for doing low
  5.                   level system stuff.
  6.     LAST MODIFIED:  30 March 1994
  7.     PROCEDURES DEFINED IN THIS FILE:
  8.         : void COLDBOOT()
  9.         : void DELAY(time)
  10.         : void DISABLE()
  11.         : void EATKEY()
  12.         : void ENABLE()
  13.         : void EOI()
  14.         : void REBOOT()
  15.         : void ROMBASIC()
  16.         : void WAIT(ticks)
  17.         : void WARMBOOT()
  18. */
  19.  
  20.  
  21. : void COLDBOOT ()
  22. {
  23. /*
  24.    A call to INT 0x19 or something to make sure it is safe to reboot, may
  25.    be required.
  26. */
  27. $ JMP FAR 0xFFFF:0000
  28. }
  29.  
  30.  
  31. : void WARMBOOT ()
  32. {
  33. /*
  34.    A call to INT 0x19 or something to make sure it is safe to reboot, may
  35.    be required.
  36. */
  37. DS = 0;
  38. DSWORD[0x472] = 0x1234;
  39. $ JMP FAR 0xFFFF:0000
  40. }
  41.  
  42.  
  43. : void REBOOT ()
  44. {
  45. $ INT 0x19
  46. }
  47.  
  48.  
  49. : void ROMBASIC ()
  50. {
  51. $ INT 0x18
  52. }
  53.  
  54.  
  55. : void ENABLE ()
  56. /* Enables interrupts by use of the STI operation.
  57. */
  58. {
  59. $ STI
  60. }
  61.  
  62.  
  63. : void DISABLE ()
  64. /* Disables interrupts by use of the CLI operation.
  65. */
  66. {
  67. $ CLI
  68. }
  69.  
  70.  
  71. : void EOI ()
  72. {
  73. AL = 0x20;
  74. $ OUT 0x20,AL
  75. }
  76.  
  77.  
  78. : void DELAY ()  /* AX = amount of time to delay in 1/15.3 second units. */
  79. /* Delays for a specified time.  AT or higher BIOS required.
  80. */
  81. {
  82. CX = AX;
  83. DX = 0;
  84. AH = 0x86;
  85. $ INT 15
  86. }
  87.  
  88.  
  89. : void EATKEY ()
  90. /* Informs the keyboard controller that the scan code has been received.
  91. */
  92. {
  93. $ IN AL,0x61
  94. AH = AL;
  95. AL |= 0x80;
  96. $ OUT 0x61,AL
  97. AL = AH;
  98. $ OUT 0x61,AL
  99. }
  100.  
  101.  
  102. : void WAIT ()     /* AX == number of ticks to wait */
  103. /*
  104.    Delay for a certain number of clock ticks (unless another program has
  105.    reprogrammed the PIT, there should be 18.2 ticks/sec).
  106.    Number of ticks to wait is passed in AX.
  107.    Modfied version of code supplied by Michael B. Martin.
  108. */
  109. {
  110.    DX = AX;
  111.    ES = 0x40;       // read daily timer value from BIOS system data area
  112.    CX = ESWORD[0x6C];
  113. do {
  114.    AX = ESWORD[0x6C];
  115.    AX -= CX;
  116.    } while(AX < DX);
  117. }
  118.  
  119. /* end of SYSTEM.H-- */